<?php

namespace app\mini\controller\v1\client;

use app\common\library\MemberVo;
use app\common\logic\BillLogic;
use app\mini\controller\Common;
use think\Request;
use think\response\Json;

class Bill extends Common
{

    public $BillLogic;

    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $this->BillLogic = new BillLogic();
    }


    /**
     * 开票历史
     * @return Json
     */
    public function index(): Json
    {
        $res = $this->exception(function () {
            $params = request()->param();
            $params['member_id'] = MemberVo::instance()->getMemberId();
            return $this->BillLogic->index($params);
        });
        return $this->response($res);
    }



    /**
     * 发票确认
     * @return Json
     */
    public function confirm(): Json
    {
        $res = $this->exception(function () {
            $params = request()->param();
            $params['member_id'] = MemberVo::instance()->getMemberId();
            return $this->BillLogic->confirm($params);
        });
        return $this->response($res);
    }


    /**
     * 一键开票
     * @return Json
     */
    public function add(): Json
    {
        $res = $this->exception(function () {
            $params = request()->param();
            $params['member_id'] = MemberVo::instance()->getMemberId();
            return $this->BillLogic->add($params);
        });
        return $this->response($res);
    }


    /**
     * 发票详情
     * @return Json
     */
    public function detail(): Json
    {
        $res = $this->exception(function () {
            $params = request()->param();
            $params['member_id'] = MemberVo::instance()->getMemberId();
            return $this->BillLogic->detail($params);
        });
        return $this->response($res);
    }


    /**
     * 发票取消
     * @return Json
     */
    public function cancel(): Json
    {
        $res = $this->exception(function () {
            $params = request()->param();
            $params['member_id'] = MemberVo::instance()->getMemberId();
            return $this->BillLogic->cancel($params);
        });
        return $this->response($res);
    }

}
